import { Component, OnInit, ViewChild } from '@angular/core';
import { apiConf } from '@conf/api.conf';
import {
  SFComponent,
  SFCustomWidgetSchema,
  SFNumberWidgetSchema,
  SFRadioWidgetSchema,
  SFSchema,
  SFSelectWidgetSchema,
  SFTextareaWidgetSchema,
  SFUISchema,
  SFUploadWidgetSchema
} from '@delon/form';
import { _HttpClient } from '@delon/theme';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';
import { Observable, Observer } from 'rxjs';
import { OrderManagementService } from '../../../services/order-management.service';

@Component({
  selector: 'app-order-management-appeal',
  templateUrl: './appeal.component.html'
})
export class OneCarOrderAppealComponent implements OnInit {
  i: any;
  dataList: any;
  constructor(
    private modalRef: NzModalRef,
    private modal: NzModalService,
    private msgSrv: NzMessageService,
    public http: _HttpClient,
    public service: OrderManagementService
  ) {}

  ngOnInit(): void {
    this.initDate();
  }
  // initSF() {
  //   this.schema = {
  //     properties: {
  //       abnormalCause: {
  //         type: 'string',
  //         title: '异常原因',
  //         default: this.i.abnormalCause,
  //         readOnly: true,
  //         ui: {
  //           widget: 'textarea',
  //           autosize: { minRows: 4, maxRows: 6 }
  //         } as SFTextareaWidgetSchema
  //       },
  //       representationsCause: {
  //         type: 'string',
  //         title: '申诉原因',
  //         ui: {
  //           widget: 'dict-select',
  //           params: { dictKey: 'bill:representation:reason' },
  //           containsAllLabel: false,
  //           placeholder: '请选择',
  //           errors: { required: '请选择' }
  //         }
  //       },
  //       representationsDescribe: {
  //         type: 'string',
  //         title: '申诉描述',
  //         maxLength: 100,
  //         ui: {
  //           widget: 'textarea',
  //           autosize: { minRows: 4, maxRows: 6 }
  //         } as SFTextareaWidgetSchema
  //       },
  //       fileArr: {
  //         type: 'string',
  //         title: '上传凭证',
  //         ui: {
  //           action: apiConf.fileUpload,
  //           accept: 'image/png,image/jpeg,image/jpg',
  //           limit: 5,
  //           limitFileCount: 5,
  //           resReName: 'data.fullFilePath',
  //           urlReName: 'data.fullFilePath',
  //           widget: 'upload',
  //           descriptionI18n: '不超过5张，单张大小不超过5M，支持.jpg、.jpeg和 .png格式',
  //           name: 'multipartFile',
  //           multiple: true,
  //           listType: 'picture-card',
  //           beforeUpload: (file: any, _fileList: any) => {
  //             return new Observable((observer: Observer<boolean>) => {
  //               const isLt2M = file.size / 1024 / 1024 < 5;
  //               if (!isLt2M) {
  //                 this.service.msgSrv.warning('图片大小超过5M!');
  //                 observer.complete();
  //                 return;
  //               }
  //               observer.next(isLt2M);
  //               observer.complete();
  //             });
  //           }
  //         } as SFUploadWidgetSchema
  //       }
  //     },
  //     required: ['representationsCause', 'representationsDescribe']
  //   };
  //   this.ui = {
  //     '*': {
  //       spanLabelFixed: 100,
  //       grid: { span: 20 }
  //     }
  //   };
  // }
  initDate(): void {
    console.log(this.i);
    this.service.request(this.service.$api_get_getOrderComplaintDetail, { id: this.i?.id }).subscribe((res: any) => {
      if (res) {
       console.log(res);
       this.dataList = res
      }
    });
  }

  close(): void {
    this.modalRef.destroy();
  }
}
